﻿<%@ Page Title="" Language="C#" MasterPageFile="~/resumemanager/resume.master" Inherits="WebManager.BasePage" %>

<%@ Import Namespace="TalentPools.Model" %>
<%@ Import Namespace="TalentPools.BLL" %>
<script runat="server">
    string username;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!MyUserLogin())
        {
            JsWindows("请先登录", "../Index.aspx");
            return;
        }
        username = Server.UrlDecode(Request.Cookies["User"].Values["name"]);
        if (!IsPostBack)
        {
            cblskill.DataSource = new baseConfigManager().getconfigInfo("技能");
            cblskill.DataTextField = "value";
            cblskill.DataValueField = "value";
            cblskill.DataBind();
            List<Skill> list = new SkillManager().GetSkill(Convert.ToInt32(Session["resumeId"]));
            if (list.Count == 0)
            {
                ViewState["skill"] = null;
            }
            else
                ViewState["skill"] = list;
            if (list.Count == 1)
            {
                string name = list[0].Name;
                string[] value = name.Split(',');
                foreach (ListItem item in cblskill.Items)
                {
                    foreach (string str in value)
                    {
                        if (str == item.Value)
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
        }
    }

    protected void btnsubmit_skill_Click(object sender, EventArgs e)
    {
        string skillStr = "";
        foreach (ListItem item in cblskill.Items)
        {
            if (item.Selected)
            {
                if (skillStr == "")
                {
                    skillStr += item.Text;
                }
                else
                {
                    skillStr += "," + item.Text;
                }
            }
        }
        Skill skill = new Skill();
        skill.Name = skillStr;
        skill.resumeId = Convert.ToInt32(Session["resumeId"]);
        bool result = false;
        if (ViewState["skill"] != null)
        {
            result = new SkillManager().UpdateSkill(skill);
        }
        else
        {
            result = new SkillManager().InsertSkill(skill);
        }
        if (result)
        {
            lblskill.Text = "操作成功！";
        }
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Panel ID="plskill" runat="server" Visible="true">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='1' class='border'>
            <tr class='tdbg'>
                <td colspan="2" class="topbg2">
                    <div align="center" class="Glow">
                        <strong>精 通 技 能</strong></div>
                </td>
            </tr>
            <tr class='tdbg'>
                <td class="tdbg1">
                    <div align="right">
                        技能项：</div>
                </td>
                <td class="tdbg2" style="width: 482px">
                    <asp:CheckBoxList ID="cblskill" Width="482px" runat="server" RepeatColumns="2" RepeatDirection="Horizontal">
                    </asp:CheckBoxList>
                </td>
            </tr>
        </table>
        <br />
        <table width="100%" border="0">
            <tr>
                <td>
                    <div align="center">
                        &nbsp;<asp:Button ID="btnsubmit_skill" runat="server" Text="提 交" OnClick="btnsubmit_skill_Click" />
                        &nbsp;
                        <label>
                            <input type="reset" name="Submit2" value="重 置" /><br />
                            <asp:Label ID="lblskill" runat="server" ForeColor="Red"></asp:Label></label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
